#!/bin/bash

#mysql的库名
  # database=college_graduate
  # table=college_graduate
   hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`
fi


sql=" 

load data inpath '/origin_data/db/college_graduate/$do_date' OVERWRITE into table cy_database.ods_college_graduate partition(dt='$do_date');

load data inpath '/origin_data/db/enterprise/$do_date' OVERWRITE into table cy_database.ods_enterprise partition(dt='$do_date');

load data inpath '/origin_data/db/company_probation_years/$do_date' OVERWRITE into table cy_database.ods_company_probation_years partition(dt='$do_date');

load data inpath '/origin_data/db/probation_company/$do_date' OVERWRITE into table cy_database.ods_probation_company partition(dt='$do_date');

load data inpath '/origin_data/db/probation_people/$do_date' OVERWRITE into table cy_database.ods_probation_people partition(dt='$do_date');

load data inpath '/origin_data/db/enterprise_business/$do_date' OVERWRITE into table cy_database.ods_enterprise_business partition(dt='$do_date');

load data inpath '/origin_data/db/job_fair/$do_date' OVERWRITE into table cy_database.ods_job_fair partition(dt='$do_date');

load data inpath '/origin_data/db/position/$do_date' OVERWRITE into table cy_database.ods_position partition(dt='$do_date');

load data inpath '/origin_data/db/enterprise_person_info/$do_date' OVERWRITE into table cy_database.ods_enterprise_person_info partition(dt='$do_date');

load data inpath '/origin_data/db/person_info/$do_date' OVERWRITE into table cy_database.ods_person_info partition(dt='$do_date');

load data inpath '/origin_data/db/out_work/$do_date' OVERWRITE into table cy_database.ods_out_work partition(dt='$do_date');

load data inpath '/origin_data/db/help_people/$do_date' OVERWRITE into table cy_database.ods_help_people partition(dt='$do_date');
 
load data inpath '/origin_data/db/unemploy_person/$do_date' OVERWRITE into table cy_database.ods_unemploy_person partition(dt='$do_date');
"
$hive -e "$sql"